/**
 * 
 */
package br.com.ridea.pegadacultural.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
* @author Bruno Henrique Dannas Pelogia <bruno.pelogia@gmail.com>
* @since 19/07/2014
* @version 1.0
*/

public class ConnectionFactory {
	//caminho do banco
	private String DRIVER = "com.mysql.jdbc.Driver";
	private String URL = "jdbc:mysql://localhost:3306/pegadacultural";
	private String USUARIO = "root";
	private String SENHA = "299172";
	
	public Connection criarConexao(){
		Connection conexao  = null;
		
        try{
        		
			Class.forName(DRIVER);
			conexao = DriverManager.getConnection(URL, USUARIO, SENHA);
		
        } catch (Exception e) {
			e.printStackTrace();
		}
		return conexao;
	}
	
	public void fecharConexao(Connection conexao, PreparedStatement pstmt, ResultSet result){
		try {
			if(conexao != null){
				conexao.close();
			}
			if(pstmt != null){
				pstmt.close();
			}
			if(result != null){
				result.close();
			}
		} catch (Exception e) {	
			e.printStackTrace();
		}
	}
}
